package com.hellpro.lolbox.home.model;

import android.content.Context;

import com.hellpro.lolbox.bean.ZXZp;
import com.hellpro.lolbox.home.HomeJsonUtils;
import com.hellpro.lolbox.utils.OkHttpClientUtils;

import java.io.IOException;

/**
 * Package_Name: com.hellpro.lolbox.home.model
 * Description :
 * author: HellPermanent
 * date:  2016/10/22 2:17
 * remarks：
 */
public class ZXLoadXRecycleData implements IZXLoadXRecycleData {
    private Context mContext;

    public ZXLoadXRecycleData(Context context) {
        mContext = context;
    }

    @Override
    public void loadRecycleData(final String url, final OnLoadXRecycleListener loadXRecycleListener) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    String json = OkHttpClientUtils.getStringFromURL(mContext, url, null);
                    if (json!=null) {
                        ZXZp data = HomeJsonUtils.getData(json, ZXZp.class);
                        loadXRecycleListener.success(data);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }
}
